home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
tools
/
czesc_4
/
smallmath
/
source
/
dpow.a
< prev
next >
Wrap
Text File
|
1993-01-24
|
3KB
|
160 lines
XDEF _IEEEDPPow
; Sorry this is such a maze, but I'm not all that experienced with assembly
; language (could you tell?). Hopefully the labels are helpful -- I tried to
; make them as clear as I could.
SECTION code
_IEEEDPPow:
movem.l d0-d3,-(sp)
fmove.d (sp)+,fp0
fmove.d (sp)+,fp1
ftst.x fp0
fbogt.w ArgPositive
fbeq.w ArgEQZero
ArgNegative:
fmove.x fp3,-(sp)
fint.x fp1,fp3
fcmp.x fp1,fp3
fbne.w ReturnNotANumber
NegativeToIntOrInf:
ftst.x fp1
fmovem.l fpsr,d0
btst.l #25,d0
bne.w ReturnNotANumber
NegativeToInteger:
fmove.x fp2,-(sp)
fscale.w #-1,fp3
fint.x fp3,fp2
fcmp.x fp3,fp2
fbeq.w NegativeToEven
NegativeToOdd:
fmovem.x (sp)+,fp2/fp3
fabs.x fp0
flogn.x fp0
fmul.x fp0,fp1
fetox.x fp1
fmove.d fp1,-(sp)
movem.l (sp)+,d0/d1
bset.l #31,d0
rts
NegativeToEven:
fmovem.x (sp)+,fp2/fp3
fabs.x fp0
flogn.x fp0
fmul.x fp0,fp1
fetox.x fp1
fmove.d fp1,-(sp)
movem.l (sp)+,d0/d1
rts
ArgPositive:
flogn.x fp0
fmul.x fp0,fp1
fetox.x fp1
fmove.d fp1,-(sp)
movem.l (sp)+,d0/d1
rts
ArgEQZero:
ftst.x fp1
ZeroToZero:
fbeq.w ReturnNotANumberNoFP3
ZeroToNonZero:
fmovem.l fpsr,d0
btst.l #25,d0
bne.w ZeroToInfinity
ZeroToReal:
ftst.x fp0
fmovem.l fpsr,d0
btst.l #27,d0
beq.w PositiveZeroToReal
NegativeZeroToReal:
fmove.x fp3,-(sp)
fint.x fp1,fp3
fcmp.x fp1,fp3
fbne.w ReturnNotANumber
NegativeZeroToInteger:
ftst.x fp1
fmovem.l fpsr,d0
btst.l #25,d0
bne.w ReturnNotANumber
fmove.x fp2,-(sp)
fscale.w #-1,fp3
fint.x fp3,fp2
fcmp.x fp3,fp2
fbeq.w NegativeZeroToEven
NegativeZeroToOdd:
fmovem.x (sp)+,fp2/fp3
ftst.x fp1
fbogt.w NegativeZeroToPositiveOdd
NegativeZeroToNegativeOdd:
move.l #$FFF00000,d0
clr.l d1
rts
NegativeZeroToPositiveOdd:
move.l #$80000000,d0
clr.l d1
rts
NegativeZeroToEven:
fmovem.x (sp)+,fp2/fp3
ftst.x fp1
fbogt.w NegativeZeroToPositiveEven
NegativeZeroToNegativeEven:
move.l #$7FF00000,d0
clr.l d1
rts
NegativeZeroToPositiveEven:
clr.l d0
clr.l d1
rts
PositiveZeroToReal:
ftst.x fp1
fbogt.w PositiveZeroToPositiveReal
PositiveZeroToNegativeReal:
move.l #$7FF00000,d0
clr.l d1
rts
PositiveZeroToPositiveReal:
clr.l d0
clr.l d1
rts
ZeroToInfinity:
btst.l #27,d0
beq.w ZeroToPositiveInfinity
ZeroToNegativeInfinity:
ftst.x fp0
fmovem.l fpsr,d0
btst.l #27,d0
beq.w PositiveZeroToNegativeInfinity
NegativeZeroToNegativeInfinity:
bra.w ReturnNotANumberNoFP3
PositiveZeroToNegativeInfinity:
move.l #$7FF00000,d0
clr.l d1
rts
ZeroToPositiveInfinity:
ftst.x fp0
fmovem.l fpsr,d0
btst.l #27,d0
beq.w PositiveZeroToPositiveInfinity
NegativeZeroToPositiveInfinity:
bra.w ReturnNotANumberNoFP3
PositiveZeroToPositiveInfinity:
clr.l d0
clr.l d1
rts
ReturnNotANumber:
fmove.x (sp)+,fp3
ReturnNotANumberNoFP3:
move.l #$7FFFFFFF,d0
move.l #$FFFFFFFF,d1
rts
END